﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <link rel="shortcut icon" href="logo.ico" type="image/x-icon" />
    <title>内容管理系统</title>

    <link rel="stylesheet" href="Content/css/bootstrap.min.css" />
    <link rel="stylesheet" href="Content/css/font-awesome.min.css" />

    <!-- ace styles -->
    <link rel="stylesheet" href="Content/css/ace.min.css" />
    <link rel="stylesheet" href="Content/css/ace-rtl.min.css" />
    <!--<link href="Content/css/ace-ie.min.css" rel="stylesheet" />-->
    <link rel="stylesheet" href="Content/css/ace-skins.min.css" />

    <link rel="stylesheet" href="Content/css/jquery-ui-1.10.3.custom.min.css" />
    <link rel="stylesheet" href="Content/css/jquery.gritter.css" />

    <link rel="stylesheet" href="Content/css/busy/ladda-themeless.css" />
    <link rel="stylesheet" href="Content/css/busy/gbtags.css" />
    <script src="Content/js/respond.min.js"></script>
    <script src="Content/js/bootstrap-2.3.2/placeholders.js"></script>

</head>

<body class="login-layout" ng-app="loginApp" ng-controller="loginCtr">
    <script type="text/javascript">

        document.onkeydown = function (e) {
            var theEvent = window.event || e;
            var code = theEvent.keyCode || theEvent.which;
            if (code == 13) {
                document.getElementById('loadbtn').click();

            }
        }

    </script>

    <div class="main-container">
        <div class="main-content">
            <div class="row">

                <div class="col-sm-10 col-sm-offset-1">

                    <div class="login-container">
                        <div class="position-relative" style="padding-top: 30%;">
                            <div id="login-box" class="login-box visible widget-box no-border">
                                <div class="widget-body">
                                    <div class="widget-main">
                                        <h4 class="header blue lighter bigger">
                                            <i class="icon-coffee green"></i>
                                            请输入你的登录信息
                                        </h4>

                                        <form class="form-horizontal">

                                            <label class="block clearfix">
                                                用户名
                                                <span class="block input-icon input-icon-right">
                                                    <input type="text" class="form-control" placeholder="Username" ng-model="username" />
                                                    <i class="icon-user"></i>
                                                </span>
                                            </label>

                                            <label class="block clearfix">
                                                密&nbsp;码
                                                <span class="block input-icon input-icon-right">
                                                    <input type="password" class="form-control" placeholder="Password" ng-model="userpassword" />
                                                    <i class="icon-lock"></i>
                                                </span>
                                            </label>

                                            <div class="space"></div>

                                            <div class="clearfix">
                                                <label class="inline">
                                                    <input type="checkbox" class="ace" ng-mode="isautologin" id="isautologin" name="isautologin" />
                                                    <span class="lbl" style="margin-left:20px">记住我</span>
                                                </label>

                                                <button type="button" class="width-35 pull-right btn btn-sm btn-primary" ng-click="onSubmit()" id="loadbtn">
                                                    <i class="icon-key"></i>
                                                    登录
                                                </button>
                                            </div>

                                            <div class="space-4"></div>

                                        </form>

                                        <!--<div class="social-or-login center">
                                                <span class="bigger-110">Or Login Using</span>
                                            </div>

                                            <div class="social-login center">
                                                <a class="btn btn-primary">
                                                    <i class="icon-facebook"></i>
                                                </a>

                                                <a class="btn btn-info">
                                                    <i class="icon-twitter"></i>
                                                </a>

                                                <a class="btn btn-danger">
                                                    <i class="icon-google-plus"></i>
                                                </a>
                                            </div>-->
                                    </div>
                                    <!-- /widget-main -->

                                    <div class="toolbar clearfix">
                                        <div>
                                            <!-- <a href="#" onclick="show_box('forgot-box'); return false;" class="forgot-password-link">
                                                <i class="icon-arrow-left"></i>
                                                忘记密码
                                            </a>-->
                                        </div>

                                        <div>
                                            <!--<a href="#" onclick="show_box('signup-box'); return false;" class="user-signup-link">重新注册
                                                    <i class="icon-arrow-right"></i>
                                            </a>-->
                                        </div>
                                    </div>
                                </div>
                                <!-- /widget-body -->
                            </div>
                        </div>
                        <!-- /position-relative -->
                    </div>
                </div>
                <!-- /.col -->
            </div>
            <!-- /.row -->
        </div>
    </div>
    <!-- /.main-container -->
    <!-- basic scripts -->
    <script type="text/javascript" src="Content/js/respond.min.js"></script>
    <script src="Content/js/jquery-1.10.2/jquery-1.10.2.min.js"></script>
    <script src="Content/js/jquery.cookie.js"></script>
    <script src="Content/js/angular-1.2.29/angular-1.2.29.min.js"></script>
    <script src="Content/js/bootstrap/jquery.bootstrap-growl.min.js"></script>
    <script src="Content/js/jquery.gritter.min.js"></script>
    <script src="Content/js/cppei/cppei.view.js"></script>
    <script src="Content/login.js"> </script>
    <script src="Content/js/busy/jquery.jribbble.min.js"></script>
    <script src="Content/js/bootstrap.min.js"></script>
    <script src="Content/js/busy/spin.js"></script>
    <script src="Content/js/busy/ladda.js"></script>
    <script src="Content/js/blockui/jquery.blockUI.js"></script>
    <script src="Content/js/cppei/cppei.view.js"></script>
    <script>
        cppei.install();

        var app = angular.module('loginApp', []);
        app.controller("loginCtr", function ($scope, $http) {

            if ($.cookie("isautologin") == "true") {
                $("#isautologin").attr("checked", true);
                $scope.isautologin = true;
                $scope.username = $.cookie("userName");
                $scope.userpassword = $.cookie("passWord");
            }

            $scope.onSubmit = function () {
                $scope.saveUserInfo();
                cppei.busy(true)
                //登录
                $http({
                    method: 'post',
                    url: 'api/account/login',
                    data: { Account: $scope.username, Password: $scope.userpassword }
                }).success(function (data, status) {
                    //debugger;
                    if (data.isSuccess) {
                        window.location.href = "index.html";
                    }
                    else {
                        cppei.growlError(data.message);
                        cppei.busy(false);
                    }
                }).error(function (data, status) {
                    cppei.growl(data.message);
                    cppei.busy(false);
                });
            }

            $scope.saveUserInfo = function () {
                var isautologin = document.getElementById('isautologin');
                if (isautologin.checked == true) {
                    var userName = $scope.username;
                    var passWord = $scope.userpassword;
                    $.cookie("isautologin", "true", { expires: 7 }); // 存储一个带7天期限的 cookie
                    $.cookie("userName", userName, { expires: 7 }); // 存储一个带7天期限的 cookie
                    $.cookie("passWord", passWord, { expires: 7 }); // 存储一个带7天期限的 cookie
                }
                else {
                    $.cookie("isautologin", "false", { expires: -1 });        // 删除 cookie
                    $.cookie("userName", '', { expires: -1 });
                    $.cookie("passWord", '', { expires: -1 });
                }
            }

        });


    </script>

    <!-- inline scripts related to this page -->
</body>
</html>

